package com.dfbz.demo02_泛型类的使用;

import com.dfbz.demo01_泛型的好处.Book;
import com.dfbz.demo01_泛型的好处.Province;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {

    public static void main(String[] args) {

        // 在创建GetClass对象的时候就明确泛型类型
        GetClass<Province> getClass=new GetClass<>();

        getClass.setP(new Province("河北","冀","华北"));
        Province p = getClass.getP();
        p.intro();

        System.out.println("-----------");

        GetClass<Book> bookGetClass=new GetClass<>();
        bookGetClass.setP(new Book("《红楼梦》","曹雪芹"));

        Book book = bookGetClass.getP();
        book.detail();
    }

}

class GetClass<P> {

    private P p;

    public P getP() {
        return p;
    }

    public void setP(P p) {
        this.p = p;
    }
}